import { executeSql } from "../util/db.js";

export const selectCategories = function(){
    let sql = "select id , name from categories";
    return executeSql(sql);
}

export const selectCategoriesId = function(id){
    let sql = "select * from categories where id = ?";
    return executeSql(sql,[id]);
}
export const deletecategories = function(id){
    let sql = "delete from categories where id = ? and state = 0;";
    return executeSql(sql,[id]);
}

export const selectCategoriesClass = function(){
    let sql = "select id , name ,slug from categories";
    return executeSql(sql);
}

export const selectCategoriesClassId = function(id){
    let sql = "select id , name ,slug from categories where id = ?";
    return executeSql(sql,[id]);
}

export const updateCategories = function(id,name,slug){ 
    let sql = "update categories set name = ? , slug = ? where id = ? and state = 0;";
    return executeSql(sql,[name,slug,id]);
}

export const addCategories = function(name,slug){ 
    let sql = "insert into categories (id,name,slug,state) values (null,?,?,0);";
    return executeSql(sql,[name,slug]);
}